//
// Created by ryan on 2021/10/22.
//

#ifndef WORK_WORK_GRAPH_HPP
#define WORK_WORK_GRAPH_HPP

#include <string>
#include <vector>
#include <mutex>
class Node;

class Edge {
public:
    Edge(Node* node, Edge* next) : target(node), next(next){}
    Node* target;
    Edge* next;
};

class Node{
private:
public:
    std::atomic<bool> visited;
    int nodeID;
    int dealTime;
    Edge* firstEdge;
    Node(int nodeID, int dealTime) : visited(false), nodeID(nodeID), dealTime(dealTime), firstEdge(NULL) {};
    void setVisited() {
        visited = true;
    }
    bool isVisited() {
        return visited;
    }
};

class Graph {
    std::vector<Node*> graph;
    std::vector<Node*> gcRoot;

    int initial(std::string& inputFile);

public:
    Graph(std::string& inputFile);
    int getNodeNumber() {
        return graph.size();
    }
    int getGCRootNumber() {
        return gcRoot.size();
    }
    Node* getGCRootNode(int index) {
        return gcRoot[index];
    }
    Node* getNode(int nodeIndex) {
        return graph[nodeIndex];
    }

};
#endif //WORK_WORK_GRAPH_HPP